package com.zts.base.resource;

import com.fasterxml.jackson.annotation.JsonProperty;

import com.zts.base.exception.CommonException;
import org.springframework.hateoas.VndErrors;
import org.springframework.util.StringUtils;

/**
 * Created by Zhangkh on 2017/5/31.
 */
public class ExceptionResource extends VndErrors.VndError {

    @JsonProperty("code")
    private String code;

    public ExceptionResource(Throwable ex) {
        super(ex instanceof CommonException ? ((CommonException) ex).getId():ex.getClass().getName(),
                StringUtils.hasText(ex.getLocalizedMessage())? ex.getLocalizedMessage(): "<null>");
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
}
